﻿namespace AnimalEventTask
{  
    public class Animal
    {
        private string name;
        private string kind;

        public event NameChangedEventHandler NameChanged;

        public Animal(string name, string kind)
        {
            this.name = name;
            this.kind = kind;
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (!value.Equals(name))
                {
                    OnNameChanged(value,name);
                }
                name = value;
            }
        }

        private void OnNameChanged(string newValue, string oldValue)
        {
            if (this.NameChanged!=null)
            {
                NameChanged(this,new NameChangedEventArgs(oldValue,newValue));
            }
        }
    }
}
